package com.zbw.common.controller.Feign;


import com.zbw.common.entity.*;
import io.github.xxyopen.model.resp.RestResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient("novel-book")
@Component
public interface BookFeign {

    @RequestMapping("book/selectBook")
    Book selectById(@RequestParam("Bid") Long Bid);

//    @RequestMapping("book/queryComment")
//    PageBean<BookCommentVO> selectCommnet
//            (@RequestBody AskBookComment ask);

    @RequestMapping("book/addVisitCount")
    void addcount(@RequestBody Long bookId);

    @RequestMapping("book/listRecBooks")
    List<Book> listRecBooksByCatId(@RequestBody Integer catId);

    @RequestMapping("book/listRank")
    List<Book> listRank(@RequestParam("type") Byte type,@RequestParam("limit") Integer limit);

    @RequestMapping("book/listBookCategory")
    List<BookCategory> listBookCategory();

    @RequestMapping("book/queryIndexCount")
    Integer queryIndexCount(@RequestParam("bookId")Long bookId);

    @RequestMapping("book/queryBookIndex")
    BookIndex queryBookIndex(@RequestParam("lastBookIndexId")Long lastBookIndexId);

    @RequestMapping("book/queryBookContent")
    String queryBookContent(@RequestParam("bookId")Long bookId,@RequestParam("lastBookIndexId") Long lastBookIndexId);

    @RequestMapping("book/queryPreBookIndexId")
    Long queryPreBookIndexId(@RequestParam("bookId")Long bookId,@RequestParam("indexNum") Integer indexNum);

    //获取
    @RequestMapping("book/queryNextBookIndexId")
    Long queryNextBookIndexId(@RequestParam("bookId")Long bookId,@RequestParam("indexNum") Integer indexNum);

    //获取章节信息
    @RequestMapping("book/queryBookContentBook")
    BookContent queryBookContentBook(@RequestParam("bookId")Long bookId,@RequestParam("bookIndexId") Long bookIndexId);

    //获取目录页信息
    @RequestMapping("book/queryIndexList")
    List<BookIndex> queryIndexList
            (@RequestParam("bookId")Long bookId,@RequestParam("orderby") String orderby,
             @RequestParam("page") Integer page,@RequestParam("pagesize") Integer pagesize);
    /**
     * 发布小说
     * @param book 小说信息
     * @param authorId 作家ID
     * @param penName 作家笔名
     * */
    @RequestMapping("book/addBook")
    RestResult<?> addBook(@RequestBody Book book,@RequestParam("authorId") Long authorId,@RequestParam("penName") String penName);



    /**
     * 更新小说状态,上架或下架
     * @param bookId 小说ID
     * @param status 更新的状态
     * @param authorId 作者ID
     * */
    @RequestMapping("book/updateBookStatus")
    void updateBookStatus(@RequestParam("bookId") Long bookId,@RequestParam("status") Byte status,@RequestParam("authorId") Long authorId);

    @RequestMapping("book/deleteIndex")
    void deleteIndex(@RequestParam("indexId")Long indexId,@RequestParam("bookId") Long bookId);

    @RequestMapping("book/updateIndexName")
    void updateIndexName
            (@RequestParam("indexId")Long indexId,@RequestParam("indexName") String indexName,
             @RequestParam("bookId")Long bookId);
        /**
     * 发布章节内容
     * @param bookId 小说ID
     * @param indexName 章节名
     * @param content 章节内容
     * @param isVip 是否收费
     * @param authorId 作者ID   */
    @RequestMapping("book/addBookContent")
    void addBookContent(@RequestParam("bookId")Long bookId,@RequestParam("indexName") String indexName,
                        @RequestParam("content")String content, @RequestParam("isVip")Byte isVip,
                        @RequestParam("authorId")Long authorId);

    @RequestMapping("book/queryIndexContent")
    String queryIndexContent(@RequestParam("indexId")Long indexId,@RequestParam("authorId") Long authorId);

    @RequestMapping("book/updateBookContent")
    void updateBookContent(@RequestParam("indexId")Long indexId,@RequestParam("indexName") String indexName
            ,@RequestParam("content") String content,@RequestParam("authorId") Long authorId);

    @RequestMapping("book/updateBookPic")
    void updateBookPic(@RequestParam("bookId")Long bookId,
                       @RequestParam("bookPic")String bookPic,
                       @RequestParam("authorId") Long authorId);

    @RequestMapping("book/addBookComment")
    void addBookComment(@RequestParam("bookId")Long id,@RequestBody BookComment comment);
}

